# Application layer - application logic
cmake_minimum_required(VERSION 3.16)

# Enable Qt auto MOC
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

# Collect sources
file(GLOB_RECURSE APPLICATION_SOURCES "*.cpp")
file(GLOB_RECURSE APPLICATION_HEADERS "*.h")

# Create application library
add_library(application STATIC
    ${APPLICATION_SOURCES}
    ${APPLICATION_HEADERS}
)

# Explicitly generate moc for AutoDoorProtocol so that its signals link correctly
set(AUTO_DOOR_PROTOCOL_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/map/auto_door/auto_door_protocol.h)
set_source_files_properties(${AUTO_DOOR_PROTOCOL_HEADER} PROPERTIES SKIP_AUTOMOC ON)
qt6_wrap_cpp(AUTO_DOOR_PROTOCOL_MOC ${AUTO_DOOR_PROTOCOL_HEADER})
target_sources(application PRIVATE ${AUTO_DOOR_PROTOCOL_MOC})


# application layer depends on kernel and infrastructure
target_link_libraries(application PUBLIC
    kernel
    infrastructure
    Qt6::Core
    Qt6::Gui  # Required for QColor and other GUI types
    Qt6::Network  # Required for QNetworkAccessManager in third_area

    $<$<TARGET_EXISTS:libmrlp>:libmrlp>
)

# Include directories
target_include_directories(application PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_SOURCE_DIR}/src
)
